<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <script src="https://cdn.staticfile.org/vue/2.4.2/vue.min.js"></script>
</head>

<body>
    <div id="app">
 <template v-if="loginType==='username'">
     <label>姓名：</label>
     <input placeholder="输入姓名">
 </template>
<template v-else>
    <label>邮箱：</label>
    <input placeholder="输入邮箱" key="email">
</template>
<button @click='toggleType'>切换</button>
    </div>
    <script>
        var vm=new Vue({
           el:'#app',
           data:{
            loginType:'username',  
           },
           methods:{
            toggleType:function(){

                   return this.toggleType=this.toggleType==='username'?'email':'username'
               }
           }
        });
    </script>
</body>

</html>